package ru.usu.gv.gui.clustering;


/**
 * @author spupyrev
 * 12.01.2009
 */
public class ClusterHelper
{
	public static int calculateDepth(Cluster cluster)
	{
		if (cluster.containsVertexes())
			return 1;

		int result = 1;
		for (Cluster subCluster : cluster.getSubClusters())
			result = Math.max(calculateDepth(subCluster) + 1, result);

		return result;
	}

	public static int calculateSubClustersCount(Cluster cluster)
	{
		if (cluster.containsVertexes())
			return 1;

		int result = 1;
		for (Cluster subCluster : cluster.getSubClusters())
			result += calculateSubClustersCount(subCluster);

		return result;
	}

	public static int calculateVertexCount(Cluster cluster)
	{
		if (cluster.containsVertexes())
			return cluster.getVertexes().size();
		else
		{
			int ret = 0;
			for (Cluster subCluster : cluster.getSubClusters())
				ret += calculateVertexCount(subCluster);
			return ret;
		}
	}

}
